package fzu.functiongather.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import fzu.functiongather.Model.Item_PulltoRefresh;
import fzu.functiongather.R;
import lombok.Getter;
import lombok.Setter;

/**
 * Created by Administrator on 2016/9/4.
 */
public class PulltoRefreshAdapter extends BaseAdapter {
    @Getter
    @Setter
    private List<Item_PulltoRefresh> list;
    private Context mContext;
    private LayoutInflater mLayoutInflater;

    public PulltoRefreshAdapter(Context context, List<Item_PulltoRefresh> list) {
        this.list = list;
        this.mContext = context;
        this.mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.item_pulltorefresh, parent, false);
            holder = new ViewHolder();
            holder.tv_express_address = (TextView) convertView.findViewById(R.id.tv_express_address);
            holder.tv_express_num = (TextView) convertView.findViewById(R.id.tv_express_num);
            holder.tv_express_name=(TextView)convertView.findViewById(R.id.tv_express_name);
            convertView.setTag(holder);
            holder.tv_express_name.setText(list.get(position).getName()+"同学");
            holder.tv_express_num.setText("有"+list.get(position).getNum()+"件快递需要代领");
            holder.tv_express_address.setText(list.get(position).getAddress());
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        return convertView;
    }



    protected class ViewHolder{
        private TextView tv_express_name;
        private TextView tv_express_num;
        private TextView tv_express_address;
    }
}
